package com.ruoyi.project.module.ljt;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.HeEventReport;
import com.ruoyi.project.service.IHeEventReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 事件上报信息Controller
 * 
 * @author ruoyi
 * @date 2023-09-02
 */
@RestController
@RequestMapping("/ljt/report")
public class LjtHeEventReportController extends BaseController
{
    @Autowired
    private IHeEventReportService heEventReportService;

    /**
     * 查询事件上报信息列表
     */
    @RequiresPermissions("project:report:list")
    @GetMapping("/list")
    public TableDataInfo list(HeEventReport heEventReport)
    {
        startPage();
        List<HeEventReport> list = heEventReportService.selectHeEventReportList(heEventReport);
        return getDataTable(list);
    }

    /**
     * 导出事件上报信息列表
     */
    @RequiresPermissions("project:report:export")
    @Log(title = "事件上报信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HeEventReport heEventReport)
    {
        List<HeEventReport> list = heEventReportService.selectHeEventReportList(heEventReport);
        ExcelUtil<HeEventReport> util = new ExcelUtil<HeEventReport>(HeEventReport.class);
        util.exportExcel(response, list, "事件上报信息数据");
    }

    /**
     * 获取事件上报信息详细信息
     */
    @RequiresPermissions("project:report:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(heEventReportService.selectHeEventReportById(id));
    }

    /**
     * 新增事件上报信息
     */
    @RequiresPermissions("project:report:add")
    @Log(title = "事件上报信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeEventReport heEventReport)
    {
        return toAjax(heEventReportService.insertHeEventReport(heEventReport));
    }

    /**
     * 修改事件上报信息
     */
    @RequiresPermissions("project:report:edit")
    @Log(title = "事件上报信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeEventReport heEventReport)
    {
        return toAjax(heEventReportService.updateHeEventReport(heEventReport));
    }

    /**
     * 删除事件上报信息
     */
    @RequiresPermissions("project:report:remove")
    @Log(title = "事件上报信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(heEventReportService.deleteHeEventReportByIds(ids));
    }
}
